<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="ec" uri="http://www.extcloud.net"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>欢迎页面</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/layout.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/management/css/update.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/javascript/plugins/boxy/boxy.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/jquery.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/management/javascript/operation.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/boxy/jquery.boxy.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/jquery.extcloudSlideMenu.js"></script>
<%@include file="/WEB-INF/view/commonJavascriptVar.jsp"%>
<script type="text/javascript">
$(function() {
	$("li.layout_search_pull_ss a").extcloudSlideMenu({
		init_hideMenu: true ,
		speed: "fast"
	}) ;
});

function addItem(name,id) {
	var callback = function(){
		var rowNum=$("#mainTable tr").length - 1;
		var rowData = "<tr><td><a href='" 
			+ context 
			+ "/management/cte/preupdate/" + id + "'>" 
			+ name + "</a></td><td><a href='javascript:void(0);' onclick=javascript:deleteItem('"+id+"',this);>删除</a></td></tr>";
		$(rowData).insertAfter($("#mainTable tr:eq("+rowNum+")"));
	};
	ajaxAdd(id,callback) ;
}

function deleteItem(id,aElement) {
	var callback = function(){
		$(aElement).parent().parent().remove();
	};
	ajaxDelete(id,callback) ;
}

function ajaxDelete(id,callback) {
	var ajaxParams = {} ;
	var url = context + "/management/cte/ajaxdelete/${category.categoryId}_" + id ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}

function ajaxAdd(id,callback) {
	var ajaxParams = {} ;
	var url = context + "/management/cte/ajaxadd/${category.categoryId}_" + id ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}
function add() {
	Boxy.load(context+'/management/search/equipment/presearchforcte',{unloadOnHide:true,title:'增加物品'});
}
</script>
</head>
<body>
<div id="layoutAll">
<table cellpadding="0" cellspacing="0" width="100%" id="layout_content">
	<tr>
		<td height="100" valign="top">
		<div id="layout_title">
		<h4>${category.categoryName}分类下的业务</h4>
		</div>
		<div id="layout_search">
		<p>&nbsp;</p>
		</div>
		<div id="layout_search_pull">
		<ul>
			<li><a href="javascript:void(0);" onclick="javascript:add();">增加</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" />
			</li>
			<li><a id="backSubmit"
				href="${pageContext.request.contextPath}/management/category/index">取消并返回首页</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			<li class="layout_search_pull_ss"><a href="#"><img
				src="${pageContext.request.contextPath}/common/images/menu_up.gif" /></a></li>
		</ul>
		</div>
		</td>
	</tr>
	<tr>
		<td valign="top">
		<div id="layout_content_body">
		<h1 align="center">${category.categoryName}分类下的业务</h1>
		<center>
		<form id="backForm"
			action="${pageContext.request.contextPath}/management/" method="post">

		<table id="mainTable" align="center" width="90%" border="1px"
			bordercolor="#D4D4D4" cellspacing="0px">
			<thead>
				<tr>
					<th>物品名称</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${category.CTEs}" var="CTE">
					<tr>
						<td><a
							href="${pageContext.request.contextPath}/management/equipment/preupdate/${CTE.equipment.equipmentId}">${CTE.equipment.equipmentName}</a></td>
						<td><a href="javascript:void(0);"
							onclick="javascript:deleteItem('${CTE.id}',this);">删除</a></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		</form>
		</center>
		</div>
		</td>
	</tr>
</table>
</div>
</body>
</html>